<template>
  <div>
    <p-table
      class="table-list-container"
      row-key="id"
      :scroll="{ x: '100%' }"
      :columns="columns"
      bordered
      :data-source="dataSource"
      v-bind="$attrs"
      v-on="$listeners"
    >
      <a
        :slot="slotName"
        slot-scope="text, record"
        @click="$emit('number-click', record)"
      >
        {{ text }}
      </a>
      <span slot="positionName" slot-scope="text, record">
        {{ fnSlot(text, record) }}
      </span>
    </p-table>
  </div>
</template>

<script>
export default {
  props: {
    dataSource: {
      type: Array,
      default: () => [],
    },
    columns: {
      type: [Array],
      default: () => [],
    },
    slotName: {
      type: String,
      default: 'product.productNo',
    },
  },
  data() {
    return {};
  },
  created() {},
  methods: {
    fnSlot(text, record) {
      if (record.positionName === null) {
        return '-';
      }
      if (record.positionName.includes('null')) {
        return '-';
      }
      return text;
    },
  },
};
</script>

<style lang="less" scoped>
.table-list-container {
  margin-top: 20px;
  margin-bottom: 40px;
}
</style>
